package com.media.publish.video_view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.media.R;


/**
 * 编辑模块、滤镜、美颜、音乐等效果添加的视图
 */
public class ListBottomView extends BaseBottomView {

    private View mView;
    private RecyclerView mRecyclerView;

    public ListBottomView(@NonNull Context context) {
        this(context, null);
    }

    public ListBottomView(@NonNull Context context, @Nullable AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public ListBottomView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init();
    }

    public void init(RecyclerView.Adapter adapter, final int posation) {
        switch (posation) {
            case 1:
            case 2:
                mView = null;
                if (mView != null) {
                    mRecyclerView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false));
                    mRecyclerView.setAdapter(adapter);
                    return;
                } else {
                    mView = LayoutInflater.from(mContext).inflate(R.layout.layout_list_bottom_view, this);
                    //强度
                    RelativeLayout harderSkincareLayout = mView.findViewById(R.id.rl_skincare_pressbar_layout);
                    //美颜、滤镜
                    LinearLayout filterSkincareLayout = mView.findViewById(R.id.ll_filter_skincare_layout);
                    //滤镜
                    LinearLayout onlyBigFilterLayout = mView.findViewById(R.id.ll_onlybigfilter_layout);
                    //音乐
                    LinearLayout bigMusicLayout = mView.findViewById(R.id.ll_bigmusic_layout);

                    harderSkincareLayout.setVisibility(GONE);
                    filterSkincareLayout.setVisibility(VISIBLE);
                    onlyBigFilterLayout.setVisibility(GONE);
                    bigMusicLayout.setVisibility(GONE);

                    mRecyclerView = mView.findViewById(R.id.rv_filter_skincare_layout);
                }
                break;
            case 3:
                mView = null;
                if (mView != null) {
                    mRecyclerView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false));
                    mRecyclerView.setAdapter(adapter);
                    return;
                } else {
                    mView = LayoutInflater.from(mContext).inflate(R.layout.layout_list_bottom_view, this);
                    //强度
                    RelativeLayout harderSkincareLayout = mView.findViewById(R.id.rl_skincare_pressbar_layout);
                    //美颜、滤镜
                    LinearLayout filterSkincareLayout = mView.findViewById(R.id.ll_filter_skincare_layout);
                    //滤镜
                    LinearLayout onlyBigFilterLayout = mView.findViewById(R.id.ll_onlybigfilter_layout);
                    //音乐
                    LinearLayout bigMusicLayout = mView.findViewById(R.id.ll_bigmusic_layout);

                    harderSkincareLayout.setVisibility(GONE);
                    filterSkincareLayout.setVisibility(GONE);
                    onlyBigFilterLayout.setVisibility(GONE);
                    bigMusicLayout.setVisibility(VISIBLE);

                    mRecyclerView = mView.findViewById(R.id.rv_music_layout);
                }
                break;
            case 4:
                mView = null;
                if (mView != null) {
                    mRecyclerView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false));
                    mRecyclerView.setAdapter(adapter);
                    return;
                } else {
                    mView = LayoutInflater.from(mContext).inflate(R.layout.layout_list_bottom_view, this);
                    //强度
                    RelativeLayout harderSkincareLayout = mView.findViewById(R.id.rl_skincare_pressbar_layout);
                    //美颜、滤镜
                    LinearLayout filterSkincareLayout = mView.findViewById(R.id.ll_filter_skincare_layout);
                    //滤镜
                    LinearLayout onlyBigFilterLayout = mView.findViewById(R.id.ll_onlybigfilter_layout);
                    //音乐
                    LinearLayout bigMusicLayout = mView.findViewById(R.id.ll_bigmusic_layout);

                    harderSkincareLayout.setVisibility(GONE);
                    filterSkincareLayout.setVisibility(GONE);
                    onlyBigFilterLayout.setVisibility(VISIBLE);
                    bigMusicLayout.setVisibility(GONE);

                    mRecyclerView = mView.findViewById(R.id.rv_onlyfilter_layout);
                    break;
                }
            case 5://界面左右滑动滤镜
                mView = null;
                if (mView != null) {
                    mRecyclerView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false));
                    mRecyclerView.setAdapter(adapter);
                    return;
                } else {
                    mView = LayoutInflater.from(mContext).inflate(R.layout.layout_list_bottom_view, this);
                    //强度
                    RelativeLayout harderSkincareLayout = mView.findViewById(R.id.rl_skincare_pressbar_layout);
                    //美颜、滤镜
                    LinearLayout filterSkincareLayout = mView.findViewById(R.id.ll_filter_skincare_layout);
                    //滤镜
                    LinearLayout onlyBigFilterLayout = mView.findViewById(R.id.ll_onlybigfilter_layout);
                    //音乐
                    LinearLayout bigMusicLayout = mView.findViewById(R.id.ll_bigmusic_layout);

                    harderSkincareLayout.setVisibility(GONE);
                    filterSkincareLayout.setVisibility(GONE);
                    onlyBigFilterLayout.setVisibility(GONE);
                    bigMusicLayout.setVisibility(GONE);

                    mRecyclerView = mView.findViewById(R.id.rv_onlyfilter_layout);
                    break;
                }
        }
        mRecyclerView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false));
        mRecyclerView.setAdapter(adapter);
    }

    public View getAllView() {
        return mView;
    }

    @Override
    protected void init() {
    }

    @Override
    public boolean isPlayerNeedZoom() {
        return false;
    }
}
